import adbutils


def enable_gps():
    # 执行adb命令开启GPS定位
    try:
        d = adbutils.adb.device()
        d.shell("pm grant com.qihoo.smart android.permission.ACCESS_FINE_LOCATION", timeout=3)
        d.shell("pm grant com.visualworld.cloudsmart android.permission.ACCESS_FINE_LOCATION", timeout=3)
    except:
        pass


def disable_gps():
    # 执行adb命令关闭GPS定位
    try:
        d = adbutils.adb.device()
        d.shell("pm revoke com.qihoo.smart android.permission.ACCESS_FINE_LOCATION", timeout=3)
        d.shell("pm revoke com.visualworld.cloudsmart android.permission.ACCESS_FINE_LOCATION", timeout=3)
    except:
        pass

# enable_gps('6HJ4C19717010629')
# disable_gps('6HJ4C19717010629')
